<template>
  <el-icon :size="size">
    <component :is="name" @click="iconClick"></component>
  </el-icon>
</template>

<script lang="ts">
import { toRefs } from 'vue'

export default {
  name: 'Icon',
  props: {
    // 图标名
    name: {
      type: String,
      default: '',
      require: true
    },
    // 图标尺寸
    size: {
      type: Number,
      default: 18
    }
  },
  setup(props, { emit }) {
    const iconClick = () => {
      emit('click')
    }
    return {
      ...toRefs(props),
      iconClick
    }
  }
}
</script>
